from pixelcount import pixelcount
from PIL import Image
def partition(img):
	pixel = []
	fragmentsVertical = 4
	fragmentsHorizontal = 3
	[a,b,width, height] = img.getbbox()
	ver=height
	hor=width
	#print a, b, height, width
	height = height / fragmentsVertical
	width = width / fragmentsHorizontal
	for idxVertical in range(0,fragmentsVertical):
		yInitial = round( idxVertical* height)
		if(idxVertical+1 == fragmentsVertical):
			yFinal=ver
		else:
			yFinal = round((idxVertical + 1) * height)
		for idxHorizontal in range(0,fragmentsHorizontal):
			xInitial=round(idxHorizontal* width)
			if(idxHorizontal+1 == fragmentsHorizontal):
				xFinal=hor
			else:
				xFinal=round((idxHorizontal+1)* width)
				
			box = [int(xInitial), int(yInitial), int(xFinal), int(yFinal)]	
			
			subImage = img.crop(box)
			[white,black]=pixelcount(subImage)
			
			pixel.append(white)
			pixel.append(black)
			
			#fid.write('%f %f ' % (white,black))
#	fid.write('\n')
	return pixel

